| 10.1 In the BinarySearchTree class, test and develop a leaves method. Here is the method specification: /** * Returns the number of leaves in this BinarySearchTree object. * The worstTime(n) is O(n). * * @return - the number of leaves in this BinarySearchTree object. * */ public int leaves() Test your method by adding tests to the BinarySearchTreeTest class available from the book's website. Hint: A recursive version, invoked by a wrapper method, can mimic the definition of leaves(t) from Section 9.1. Or, you can also develop an iterative version by creating a new iterator class in which the next method increments a count for each Entry object whose left and right fields are null. | |
| View Solution | |
| Next >> | |